#include <QHBoxLayout>
#include <QIntValidator>
#include <QLineEdit>

#include "InputBox.h"


InputBox::InputBox()
{
    setAttribute(Qt::WA_DeleteOnClose, false);
    setAttribute(Qt::WA_QuitOnClose, false);

    _lineEdit = new QLineEdit(this);
    connect(_lineEdit, SIGNAL(returnPressed()), SLOT(OnReturn()));
    
    _lineEdit->setValidator(new QIntValidator(_lineEdit));
    _lineEdit->resize(150, 20);

    QHBoxLayout* mainLayout = new QHBoxLayout(this);
    mainLayout->addWidget(_lineEdit);
    setLayout(mainLayout);

    setWindowTitle(tr("Enter referral number:"));
    resize(250, 50);
}

void InputBox::OnReturn()
{
   emit enteredValue(_lineEdit->text().toAscii());
   _lineEdit->clear();
   hide();
}

